<script lang="ts" setup>
import { HttpStatusCode } from 'axios'
import { ElMessage } from 'element-plus'
import { editDictItem } from '../../../../api/dict'

const emits = defineEmits(['increase', 'closeShow'])
const props = defineProps<{
  dataForm: ListDictItem
}>()
const submitData = async () => {
  const res = await editDictItem(props.dataForm.id, props.dataForm)
  if(res.statusCode === HttpStatusCode.Ok) {
    emits('increase', 1)
    emits('closeShow')
    ElMessage({
      message: '修改成功',
      type: 'success'
    })
  } else {
    ElMessage({
      message: '修改失败',
      type: 'error'
    })
  }
}
</script>

<template>
  <el-form
      label-position="top"
      label-width="100px"
      :model="props.dataForm"
      style="max-width: 460px"
  >
    <el-form-item label="属性名">
      <el-input v-model="props.dataForm.item_label" />
    </el-form-item>
    <el-form-item label="属性值">
      <el-input v-model="props.dataForm.item_value" />
    </el-form-item>
  </el-form>
  <el-button type="primary" @click="submitData">提交</el-button>
</template>

<style lang="less" scoped>

</style>
